﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NRapid
{
    public class AngularControllerBuilder
    {
        private string ngController;
        private BaseAction action;
        public AngularControllerBuilder(BaseAction action, string ngController)
        {
            this.action = action;
            this.ngController = ngController;
            this.action.ContentType = "application/json;charset=utf-8";
            this.action.Write(string.Format("function {0}($scope){{", ngController));
        }
        public AngularControllerBuilder AddModel(string ngModel, string json)
        {
            this.action.Write(string.Format("$scope.{0}={1};", ngModel, json));
            return this;
        }
        public AngularControllerBuilder AddScript(string javascript)
        {
            this.action.Write(javascript);
            return this;
        }
        public void Return()
        {
            this.action.Write("}");
        }
    }
}
